import json
import os
import time

import requests

url = 'http://auto.eff.xiaomi.srv/admin/test/testTaskAll'



response = requests.get(url)
cookie = {
    'cookie': '_aegis_cas=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3MzQ2ODcwMDcsImRlcGlkIjoiK1x1MDAxYkxpMVx1MDAwMXtjbV5cXFx1MDAxYSFcdTAwMTVVXHUwMDBiXHUwMDA2XHUwMDBlXHUwMDExOlJhRlx1MDAxNFZcZlx0fFx1MDAwZV1WYkdcdTAwMTBSIiwiYXVkIjoiYXV0by5lZmYueGlhb21pLnNydiIsImMiOjAsImRldGFpbCI6IibbN0c5x3KLXHL2I8eZVlvyK--VgaJcdTAwMTnRZGfuwFNcdTAwMThmhKOijao--UZ2XHUwMDE5s1x1MDAwNdaWrse-gtf2qlx1MDAxOWVcdTAwMGZCqdtEJVx1MDAxZOilQakmwanah65CkZ9cL6yEXv9cdTAwMGIx-WSOXHUwMDAxSeZPP-DdMFx1MDAwMFx1MDAxY7-rc-Vu0b2F6vtPXHUwMDBlK9z-l_NuZMjZXHUwMDEyqfuVXHUwMDAwklxcZJrYT7jCRXd43qozg1x1MDAxZDZcdTAwMDJCliluwyT8rcBDJ-6hmWtzXHUwMDBmXHUwMDFhhVxm7aO4t-BcdTAwMWVcdTAwMGK2nlx1MDAxZD6NRE3xXHUwMDE5oeTEKeSV76O1c1x1MDAwYrmZ9pDVJzr9T1x1MDAwMu854sbG-_3yoNk5XHUwMDE1oyh3viuzQqauV1x1MDAxZfXJh463vTd8pqV8jj9cdTAwMThYv99N6UJ1_MCg1lx1MDAxYzfMKNBcIuiLXHUwMDFh7kpcdTAwMDcuxJxxJPSmh5KsXGKh4ZfdVqWaOrSVXHUwMDBiN0q_Wje8PtaeoHzeeUmJuOlmLFx1MDAwM1x1MDAxZVx1MDAxNkEwotLCuK1yiSB-x1x1MDAwNLh3q8ZsXHUwMDFmcWC-Mb2-dFxiTXTGYSPe5aZlVNclr_-t3JKPsHDqTp48olx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cAtcTulQoF8rfB4rJFOkXcxLkG2XCJcdTAwMTkgy1xmUrJpOYbLveXfd7dZJqVcdTAwMWYtXHUwMDFhXCKek02cd8pcXMlIK8U8oFx1MDAwMSpXwXL-nVx1MDAxMp20YXrtLlM0XHUwMDE4UVx1MDAwZrNcdTAwMTiDQG2oXHUwMDE2yVpm63xcdTAwMDVh-oJJODdB8XMzVOyC-8PXo0lp41x1MDAxMvNAmFx1MDAxNlx0Y_WKYO-4yDNOXHUwMDBiIddcZm5Wj5BeLrprXHUwMDEwpHPrXHUwMDBldVx1MDAxMCjQ_SpJLYBcItb5UCRcdTAwMTfuS32YSDeip9VcdTAwMTbSQPDIXHUwMDExO-xcdTAwMGVb6Fq_g7t8w1nxVEylrDeHyZ_NXrj6bi1HkoMu8M3nXHUwMDFlblx1MDAxZI5cdTAwMDEjXHUwMDFiS9pdXFwhW0_OXHUwMDEwJ4VcdTAwMDVeWtFIPbClnFxcqlx1MDAwZlx1MDA3ZoS0wcElgruOWlxy691WXHUwMDFjXHUwMDFhuHF3dVx1MDAxMDVe93dUXC96dUVcXFx1MDAxMKghu7EjgFx1MDAwMK945DaCM4_Hr1x00IR9blx1MDAxNzowRm-QMboiLCJzdWIiOiJsaXdlaTY4IiwidCI6ImZhbHNlIiwidXQiOiJcdTAwMDM_XHUwMDA2TVx0QlZRIiwiZXhwIjoxNzM2MzkxODgyLCJkIjoiNjU5MjM0ZTIyODAzOWRiYzZjMDY3Y2U3NjMwNzliMjQiLCJpc3MiOiJNSS1JTkZPU0VDIiwibCI6IiVcdTAwMWE4XHUwMDExVlxuIiwidHlwIjoiY2FzIn0.OfFsWl-KwLfrydoc6xmOrRlwYnJ5B6YHNpYLy4H8fDFGGhuPZNg2678aRRStMiHrjjnUv5v_WU-G5J9eALuTig'
}
data ={
  "dateRange": [
    "2024-08-01",
    "2025-01-07"
  ],
  "problemDesc": "",
  "taskStatus": ['FINISH_CHECK'],
  "testType": [],
  "freshFlag": 0.5567514785271677,
  "index": 1,
  "size": 200000
}
json_data = json.dumps(data)
ht = 'http://auto.eff.xiaomi.srv/deliver/submit-test/view/'
# 发送请求
response = requests.post(url, headers=headers,data=json_data)

jj = response.json()['data']['list']


# for i in jj:
#     str1 = i['gerrit']
#     if str1 != '' and str1 != None and "4789059" in i['gerrit']:
#         print(i['testVersion'] + '====' + i['problemDesc'] + '====' + ht + str(i['id']))

# array = [4789059,4758608,4758608,4357882,4751208,4777297,4778175,4730466,4805568,4801776,4806687,4807912,4800389,4807975,4803707,4809603,4743623,4764543,4811600,4815806,4770891,4802095,4679405,4818383,4807779,4659410,4822022,4824048,4824718,4827274,4827262,4816703,4816205,4823070,4823385,4828474,4823738,4828780,4833241,4833690,4834892,4837181,4840073,4843253,4822748,4690223,4842917,4844980,4805380,4703445,4748414,4832224,4846739,4791607,4834647,4818822,4825380,4849837,4805223,4850104,4865212,4783115,4865353,4894807,4895129,4873387,4896113,4851996,4895939,4812208,4881375,4855394,4849534,4375506,4868712,4898720,4840209,4908133,4906431,4851817,4430782,4829472,4223268,4857617,4838311,4853927,4856674,4824257,4846573,4871561,4860555,4876615,4855471,4877291,4878795,4881732,4723574,4837656,4840320,4876144,4881954,4734065,4900012]
array = [4920391]


def test(aJson,index):

    httpurl1 = ''
    tv1 = ''
    desc1 = ''
    for i in aJson:
        str1 = i['gerrit']
        str2 = i['featuresTested']



        if (str1 == '' or str1 == None or str2 == None or str2 == '' ):
            continue

        if (index in str1 or index in str2):
            httpurl1 += ht + str(i['id']) + '\n'
            tv1 += i['testVersion'] + '\n'
            desc1 += i['problemDesc'] + '\n'
            # print(ht + str(i['id']) + '====' + i['testVersion'] + '====' + i['problemDesc'])
    print(index)
    print(httpurl1)
    print(tv1)
    print(desc1)


for one in array:
    # print(one)
    test(jj,str(one))

